Skip to content

[feat] Add triggers domain and event catalog#4738

Draft
junaway wants to merge 1 commit into
wp0-connections-extractfrom
wp1-events-catalog
Draft

[feat] Add triggers domain and event catalog#4738
junaway wants to merge 1 commit into
wp0-connections-extractfrom
wp1-events-catalog

Conversation

@junaway

@junaway junaway commented Jun 18, 2026

Copy link
Copy Markdown
Contributor

Context

Triggers are the inbound dual of webhooks: Composio provider events that invoke Agenta workflows, the way Agenta events already POST to user endpoints. This lane adds the triggers domain skeleton and the first working slice, the event catalog, so the UI and later lanes have a real domain and a real catalog API to build against.

Changes

Adds the triggers domain modeled on the shipped tools domain:

  • core/triggers/TriggersService, the provider-keyed adapter port TriggersGatewayInterface, exceptions, and the Composio adapter plus its catalog reader.
  • apis/fastapi/triggers/ — the catalog routes: list/fetch providers, and list/fetch events for a provider integration. Responses are cached for five minutes; the catalog is global, not per-project.
  • A dedicated permission triad VIEW_TRIGGERS / EDIT_TRIGGERS / RUN_TRIGGERS, registered in the role defaults (viewer gets VIEW, annotator gets RUN, editor gets EDIT), mirroring the tools triad. Triggers are gated on their own permission, not on VIEW_TOOLS.

The catalog routes reuse the connections domain from the base lane: a trigger catalog is read against a connected integration.

Tests / notes

  • Triggers catalog acceptance tests run in both OSS and EE. The adapter-dependent paths are gated on COMPOSIO_API_KEY, matching the shipped tools and connections suites.
  • dbs/postgres/triggers/ is an empty package here; the subscription and delivery tables arrive in the WP3 lane.

Copilot AI review requested due to automatic review settings June 18, 2026 16:13
@vercel

vercel Bot commented Jun 18, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
agenta-documentation Ready Ready Preview, Comment Jun 18, 2026 4:32pm

Request Review

@coderabbitai

coderabbitai Bot commented Jun 18, 2026

Copy link
Copy Markdown

Important

Review skipped

Draft detected.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: c7bf8573-5008-4c18-9531-16d77c165ab7

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch wp1-events-catalog

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@junaway junaway changed the base branch from main to wp0-connections-extract June 18, 2026 16:14

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Not ready to approve

The new triggers router currently turns “unknown provider” cases into HTTP 500s and several new Pydantic models use mutable defaults that diverge from established repo conventions.

Pull request overview

This PR introduces a new Triggers domain (read-only event catalog backed by Composio) and refactors tool connection persistence into a shared Connections domain backed by the renamed gateway_connections table, wiring both into the FastAPI entrypoints and adding OSS/EE acceptance coverage.

Changes:

  • Add /triggers/catalog/* endpoints, DTOs, registry/service layers, and a Composio triggers adapter.
  • Extract tool connection auth + persistence into a standalone core/connections domain and Postgres DAO/DBE (gateway_connections), including an Alembic rename migration.
  • Add OSS + EE acceptance tests for triggers catalog and /tools/connections contract, and update wiring/permissions.
File summaries
File Description
api/oss/tests/pytest/unit/models/test_lifecycle_conventions.py Updates lifecycle convention module list to reference connections DBEs.
api/oss/tests/pytest/acceptance/triggers/test_triggers_catalog.py Adds OSS acceptance tests for triggers catalog endpoints.
api/oss/tests/pytest/acceptance/triggers/init.py Package init for OSS triggers acceptance tests.
api/oss/tests/pytest/acceptance/tools/test_tools_connections.py Adds OSS acceptance tests pinning /tools/connections behavior.
api/oss/src/dbs/postgres/triggers/init.py Introduces triggers DB package placeholder.
api/oss/src/dbs/postgres/connections/mappings.py Maps Connections DTOs to/from the new Connection DBE.
api/oss/src/dbs/postgres/connections/dbes.py Adds ConnectionDBE mapped to gateway_connections.
api/oss/src/dbs/postgres/connections/dao.py Adds ConnectionsDAO for CRUD/query operations on gateway_connections.
api/oss/src/dbs/postgres/connections/init.py Package init for Postgres connections module.
api/oss/src/core/triggers/service.py Adds triggers orchestration for provider/event catalog operations.
api/oss/src/core/triggers/registry.py Adds adapter registry for triggers providers.
api/oss/src/core/triggers/providers/composio/catalog.py Implements Composio triggers catalog HTTP calls + parsing.
api/oss/src/core/triggers/providers/composio/adapter.py Adds Composio triggers adapter (catalog + subscription verbs).
api/oss/src/core/triggers/providers/composio/init.py Lazy import wrapper for Composio triggers adapter.
api/oss/src/core/triggers/providers/init.py Package init for triggers providers.
api/oss/src/core/triggers/interfaces.py Defines triggers gateway interface contract.
api/oss/src/core/triggers/exceptions.py Adds triggers domain exceptions.
api/oss/src/core/triggers/dtos.py Adds triggers domain DTOs for providers/events.
api/oss/src/core/triggers/init.py Package init for triggers domain.
api/oss/src/core/tools/service.py Refactors tools service to delegate connection ops to ConnectionsService.
api/oss/src/core/tools/providers/composio/adapter.py Removes connection-auth verbs from tools adapter (now in connections adapter).
api/oss/src/core/tools/interfaces.py Removes DAO/connection-auth methods from tools gateway interface.
api/oss/src/core/tools/dtos.py Removes tool-connection DTOs now owned by connections domain.
api/oss/src/core/connections/utils.py Renames module docstring; continues to host oauth state helpers.
api/oss/src/core/connections/service.py Adds ConnectionsService owning gateway connections lifecycle.
api/oss/src/core/connections/registry.py Adds adapter registry for connection providers.
api/oss/src/core/connections/providers/composio/adapter.py Introduces Composio connection-auth adapter (initiate/status/refresh/revoke).
api/oss/src/core/connections/providers/composio/init.py Lazy import wrapper for Composio connections adapter.
api/oss/src/core/connections/providers/init.py Package init for connections providers.
api/oss/src/core/connections/interfaces.py Defines DAO + gateway interfaces for connections domain.
api/oss/src/core/connections/exceptions.py Adds connections domain exceptions.
api/oss/src/core/connections/dtos.py Adds connections domain DTOs (Connection/Usage + adapter request/response).
api/oss/src/core/connections/init.py Package init for connections domain.
api/oss/src/apis/fastapi/triggers/router.py Adds FastAPI router exposing triggers catalog endpoints (+ caching/EE auth).
api/oss/src/apis/fastapi/triggers/models.py Adds FastAPI response envelope models for triggers catalog.
api/oss/src/apis/fastapi/triggers/init.py Package init for FastAPI triggers API.
api/oss/src/apis/fastapi/tools/router.py Switches oauth state decoding import to connections domain utils.
api/oss/src/apis/fastapi/tools/models.py Switches tool connection envelopes to use connections domain DTOs.
api/oss/databases/postgres/migrations/core_oss/versions/oss000000002_rename_tool_connections_to_gateway_connections.py Alembic rename migration for tool_connections → gateway_connections (+ constraint/index renames).
api/entrypoints/routers.py Wires up connections + triggers services/routers and closes adapters on shutdown.
api/ee/tests/pytest/acceptance/triggers/test_triggers_catalog.py Adds EE acceptance tests for triggers catalog.
api/ee/tests/pytest/acceptance/triggers/init.py Package init for EE triggers acceptance tests.
api/ee/tests/pytest/acceptance/tools/test_tools_connections.py Adds EE acceptance tests for /tools/connections behavior.
api/ee/tests/pytest/acceptance/tools/init.py Package init for EE tools acceptance tests.
api/ee/src/core/access/permissions/types.py Adds triggers permissions and includes VIEW_TRIGGERS in default permissions.

Copilot's findings

Comments suppressed due to low confidence (1)

api/oss/src/apis/fastapi/triggers/models.py:37

  • events uses a mutable default ([]). Use Field(default_factory=list) to avoid shared mutable state across model instances and to match the project’s established Pydantic conventions.
class TriggerCatalogEventsResponse(BaseModel):
    count: int = 0
    total: int = 0
    cursor: Optional[str] = None
    events: List[TriggerCatalogEvent] = []

  • Files reviewed: 14/20 changed files
  • Comments generated: 7

Note

Your feedback helps us improve the quality of this feature.
Please use 👍 or 👎 to tell us whether this assessment is correct.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +19 to +20
from oss.src.core.triggers.exceptions import AdapterError
from oss.src.core.triggers.service import TriggersService
Comment on lines +36 to +55
def decorator(func):
@wraps(func)
async def wrapper(*args, **kwargs):
try:
return await func(*args, **kwargs)
except AdapterError as e:
cause = e.__cause__
if not (
isinstance(cause, httpx.HTTPStatusError)
and cause.response is not None
and cause.response.status_code == status.HTTP_401_UNAUTHORIZED
):
raise

raise HTTPException(
status_code=status.HTTP_424_FAILED_DEPENDENCY,
detail=e.message,
) from e

return wrapper
Comment on lines +1 to +5
from enum import Enum
from typing import Any, Dict, List, Optional

from pydantic import BaseModel

Comment on lines +33 to +35
#
categories: List[str] = []
logo: Optional[str] = None
Comment on lines +1 to +5
from typing import List, Optional

from pydantic import BaseModel

from oss.src.core.triggers.dtos import (
Comment on lines +22 to +25
class TriggerCatalogProvidersResponse(BaseModel):
count: int = 0
providers: List[TriggerCatalogProvider] = []

Comment on lines +5 to +7
Under EE the catalog is gated on the VIEW_TOOLS permission (the triggers domain
shares the gateway permission surface with tools); a developer role carries
VIEW_TOOLS, so this verifies the endpoint behaves once the gate is satisfied.
… adapter

Stand up the inbound triggers domain mirroring tools (action -> event): the
read-only events catalog and ComposioTriggersAdapter behind TriggersGatewayInterface
(list/get events, create/set-status/delete subscription on ti_* instances).

- New core/triggers, apis/fastapi/triggers, dbs/postgres/triggers (skeleton).
- Verified Composio v3 REST paths (triggers_types, trigger_instances/...).
- Dedicated VIEW_TRIGGERS permission (own triad, viewer default); not VIEW_TOOLS.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@junaway junaway force-pushed the wp1-events-catalog branch from aabbf52 to 87e5041 Compare June 18, 2026 16:31
@jp-agenta jp-agenta changed the title [feat] Add triggers catalog [feat] Add triggers domain and event catalog Jun 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants